package academic.emailClient.control.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;

import academic.emailClient.model.EmailClientModel;
import academic.emailClient.model.entities.Filter;
import academic.emailClient.view.EmailClientViewInterface;

public class FilterMenuButtonMessageListener implements ActionListener{
	private EmailClientViewInterface view;
	private EmailClientModel model;
	
/**
 * constructor
 * 	
 * @param view
 * @param model
 */
	public FilterMenuButtonMessageListener(EmailClientViewInterface view, EmailClientModel model) {
		super();
		this.view = view;
		this.model = model;
	}

	/**
	 * Handle Filter Menu Button nMessage event
	 */
	public void actionPerformed(ActionEvent e) {
		try {
			view.addManageFiltersComboBoxChangedListener(new ManageFiltersComboBoxChangedListener(view, model));
			view.addUpdateFilterButtonActionListener(new UpdateFilterButtonActionListener(view, model));
			view.addCancelModifyFilterActionListener(new CancelModifyFilterActionListener(view, model));
			view.addDeleteFilterActionListener(new DeleteFilterActionListener(view, model));
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
		HashMap<String, String> paths=model.getAllSubfoldersPaths();
		ArrayList<Filter> filters = model.getFilters();
		view.showFilterView(paths);
		view.showManageFilters(paths, filters);
	}

}

